import { getPatientConsultOrderDetailAPI } from '@/apis/consult'
import { getPatientMedicineOrderDetailAPI } from '@/apis/medicine'
import type { GetPatientConsultOrderDetailData } from '@/types/consult'
import type { MedicineOrderDetail } from '@/types/medicine'
import { ref } from 'vue'

/**
 * 获取药品订单详情
 * @param orderId 订单ID
 * @returns 订单详情
 */
export const useMedicineOrderDetail = (orderId: string) => {
  // 响应式数据
  const orderDetail = ref<MedicineOrderDetail>()

  // 获取订单详情
  const getOrderDetail = async () => {
    if (!orderId) return
    const res = await getPatientMedicineOrderDetailAPI(orderId)
    orderDetail.value = res.data
    // console.log('药品订单详情', orderDetail.value)

  }
  getOrderDetail()

  // 可返回响应式数据
  return { orderDetail, getOrderDetail }
}

/**
 * 获取咨询订单详情
 * @param orderId 订单ID
 * @returns 订单详情
 */
export const useConsultOrderDetail = (orderId: string) => {
  const orderDetail = ref<GetPatientConsultOrderDetailData>()
  const getOrderDetail = async () => {
    const res = await getPatientConsultOrderDetailAPI(orderId)
    orderDetail.value = res.data
  }
  getOrderDetail()
  return { orderDetail, getOrderDetail }
}